<?php

namespace backend\models;

use Yii;
use backend\models\GrpBrand;
use backend\models\GrpCity;

/**
 * This is the model class for table "grp_brand_city".
 *
 * @property integer $brand_id
 * @property integer $city_id
 */
class GrpBrandCity extends \yii\db\ActiveRecord
{
    public $province,$city,$sort,$brand;
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'grp_brand_city';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['brand_id', 'city_id'], 'required'],
            [['brand_id', 'city_id','sort','brand'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'brand_id' => 'Brand ID',
            'city_id' => 'City ID',
            'sort' => '分类',
            'brand' => Yii::t('app', 'Brand Name'),
            'province' => '省份',
        ];
    }
    
    public function getBrandid0()
    {
        return $this->hasOne(GrpBrand::className(), ['id'=>'brand_id']);
    }
    public function getCityid0()
    {
        return $this->hasOne(GrpCity::className(), ['id'=>'city_id']);
    }
    //获取品牌名
    public static function brand($sort_id)
    {
        return GrpBrand::find()->where(['head_grp'=>$sort_id])->asArray()->all();
    }
}
